Skip to content

feat(libkernel): add process, path and clock exports - #3654

Closed
MarcZX10 wants to merge 6 commits into
boykopovar:mainfrom
MarcZX10:codex/libkernel-ps5mc-process-3632
Closed

MarcZX10 wants to merge 6 commits into
boykopovar:mainfrom
MarcZX10:codex/libkernel-ps5mc-process-3632

Conversation

@MarcZX10

Copy link
Copy Markdown
Contributor

What

Carries the four commits from David’s ready branch linked in issue #3632, preserving his authorship. Adds getpriority, chflags, chroot, and clock_settime for the predicted PS5MC and Porpoise import stops. The issue records the pinned FreeBSD 11.4 references and the behavior each export can support.

The implementation follows the FreeBSD error checks where the relevant guest state is known. getpriority reports nice 0 for the single guest process and throws for unknown priority identities; chflags and chroot resolve guest paths and return lookup errors, then throw when the host cannot reproduce the requested state; valid CLOCK_REALTIME updates throw instead of changing the host clock. The limitations and unverified console details are recorded in TechnicalDebt. These title stops remain predicted; no title run has observed them.

This is independent of #3650. I kept the Process.cpp and TechnicalDebt changes in separate hunks and verified Git can merge both branches without conflicts.

Tested

  • Linux, GCC 12.2, Release: built the affected targets and tests; guest_sched_priority, guest_filesystem, guest_kernel_sys, and guest_freebsd_clocks passed 4/4.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD passed.
  • The issue author reports a Windows 11 Pro 26220 / WinLibs GCC 15.2.0 Release full build and neighboring test-suite results in #3632. I did not independently run Windows or a title.

Checklist

  • Based on current main; no other open PR implements these functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

David and others added 6 commits October 11, 2026 14:49
PS5MC (PPSA99420, Kodi 22) imports getpriority (miQ1wVwSexE) from
libkernel.prx, one reference, next to chflags in its import order.
Predicted stop once the imports ahead of it are covered (not a run):

  FAIL: unresolved ELF import miQ1wVwSexE from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/kern_resource.c sys_getpriority
(8c639945a44588f6cfdddfb057bb5aad88735da0) for the only guest process,
taken to run at nice 0 and to lead its own process group (as kill and
setsid already assume): PRIO_PROCESS and PRIO_PGRP with 0 or its pid,
and PRIO_USER with 0 or its uid 0, return 0; other ids give ESRCH and
an unknown which gives EINVAL. getpriority is a bare system call in
FreeBSD's libc (lib/libc/sys/Symbol.map), so errno is left unchanged
on success.


Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
PS5MC (PPSA99420, Kodi 22) imports chflags (ixrw0h2tWuI) from
libkernel.prx, one reference. Predicted stop once the imports ahead of
it (pthread_getthreadid_np, sendfile, wcstok, pause, setrlimit and the
termios calls) are covered (not a run):

  FAIL: unresolved ELF import ixrw0h2tWuI from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 (8c639945a44588f6cfdddfb057bb5aad88735da0)
sys/kern/vfs_syscalls.c kern_chflagsat and setfflags, and
sys/ufs/ufs/ufs_vnops.c ufs_setattr, for a root caller: the lookup
through the guest resolver gives EFAULT, ENOENT and ENOTDIR (also for a
file reached through a trailing slash or used as a directory), a bit
outside the 17 UFS flags of sys/sys/stat.h (VNOVAL included) gives
EOPNOTSUPP, and SF_SNAPSHOT gives EPERM, since the snapshot flag cannot
be toggled. No host keeps BSD file flags and stat reports st_flags 0,
so flags 0 succeed without touching the file and any other flag throws
with the flags named. UF_READONLY and the other Windows-attribute flags
are not mapped to FILE_ATTRIBUTE_READONLY and its siblings: UFS stores
them without enforcing them, and on Windows the read-only attribute is
already the owner write bit of chmod.


Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Porpoise (PPSA99764) imports chroot (AKknh8Cx-V8) from
libkernel_sys.prx, not libkernel.prx, one reference. Predicted stop
once pathconf, the pthread_attr calls and ftrylockfile ahead of it are
covered (not a run):

  FAIL: unresolved ELF import AKknh8Cx-V8 from libkernel_sys.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/vfs_syscalls.c sys_chroot and change_dir
(8c639945a44588f6cfdddfb057bb5aad88735da0) for a root caller up to the
lookup: EFAULT for a null path, ENOENT for an empty or missing one,
ENOTDIR for a file or a path through a file. A directory that is found
throws with the path named: the resolver's root is fixed and the mount
aliases (/app0, /savedata0) are host paths that do not move with it,
so it cannot be re-based, and a real chroot is not modelled. Nothing
shows that Porpoise calls it.


Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
PS5MC (PPSA99420, Kodi 22) imports clock_settime (d7nUj1LOdDU) from
libkernel.prx, one reference, after sigwaitinfo in its import order.
Predicted stop once the imports ahead of it are covered (not a run):

  FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/kern_time.c sys_clock_settime and
kern_clock_settime (8c639945a44588f6cfdddfb057bb5aad88735da0) for a
root caller: EFAULT for a null time (copyin), EINVAL for any clock but
CLOCK_REALTIME and for a negative tv_sec or a tv_nsec outside 0 to
999999999. A valid CLOCK_REALTIME request throws with the requested
time named, since the host clock must not be set and no guest clock
offset is kept.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Progress report (a11c8f7 → 1ab09ca)

📈 System libraries: 85.83% (+0.02%, +4 implemented functions)

✅ 4 implemented
Library Name
libkernel chflags_nid_postfix
libkernel clock_settime_nid_postfix
libkernel getpriority_nid_postfix
libkernel_sys chroot_nid_postfix

@blawesom

Copy link
Copy Markdown
Contributor

Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 832/832 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Same as #3651: getpriority, chflags, chroot and clock_settime are predicted stops only, and three of them throw once the arguments are valid. Reopen when a title run stops at one, one function per PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs libkernel needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants